package edu.sctu.practice.class02.yangshengyu.assign03.teat02;

import java.lang.*;

/**
 * Created by Cullen on 2015/10/24.
 */
public class ComparableCylinder extends Cylinder implements Comparable {


    public ComparableCylinder(double r, double height) {
        this.r = r;
        this.height = height;
    }

    @Override
    public int compareTo(Object o) {
//         double c = Math.max(getArea(),((ComparableCylinder)o).getArea());
        if (getArea() > ((ComparableCylinder) o).getArea()) {
            return 0;
        } else {
            return 1;
        }
    }

    private double getArea() {
        return r * r * Math.PI * 2 + r * 2 * Math.PI * height;
    }
}
